package com.example.utils;

import com.example.enums.CodeEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author 王鹤蒲
 * @Date 2023 08 01
 */
@Data
public class R implements Serializable {

    private Integer code;

    private Object msg;

    private Object data;

    public R(){

    }

    public R(Integer code,Object msg){
           this.code=code;
           this.msg=msg;
    }


    public R(Integer code,String msg,Object data){
        this.code=code;
        this.msg=msg;
        this.data=data;
    }

    public static R success(){
      return new R(CodeEnum.SUCCESS.getCode(),"");
    }

    public static R success(Object data){
      return new R(CodeEnum.SUCCESS.getCode(),"",data );
    }


    public static R error(){
        return new R(CodeEnum.SYSTEM_ERROR.getCode(),CodeEnum.SYSTEM_ERROR.getMsg());
    }

    public static R error(Integer code,Object msg){
        return new R(code,msg);
    }

}
